package com.huan.table;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class TableBean implements Writable {


    private String id;  //订单id
    private String pid; //产品id
    private int amount; //数量
    private String name; //产品名称
    private String flag; //定义一个标记，标记是订单表还是产品表

    public TableBean() { }

    public TableBean(String id, String pid, int amount, String name, String flag) {
        this.id = id;
        this.pid = pid;
        this.amount = amount;
        this.name = name;
        this.flag = flag;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }


    @Override
    public String toString() {
        return id + '\'' +  name + '\''+ amount ;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF( id );
        out.writeUTF( pid );
        out.writeInt( amount );
        out.writeUTF( name );
        out.writeUTF( flag );

    }

    @Override
    public void readFields(DataInput in) throws IOException {
        id = in.readUTF();
        pid = in.readUTF();
        amount = in.readInt();
        name = in.readUTF();
        flag = in.readUTF();
    }
}
